﻿Public Class dmLoaiHangMuc
    Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean
        If keyData = (Keys.Control Or Keys.N) Then
            Return Me.DmloaihangmucIUltraGrid.getTaoMoi()
        End If
        If keyData = (Keys.Control Or Keys.S) Then
            Me.DmloaihangmucIUltraGrid.getLuu()
            Return True
        End If
        If keyData = (Keys.Control Or Keys.D) Then
            Return Me.DmloaihangmucIUltraGrid.getXoa()
        End If
        If keyData = (Keys.Control Or Keys.P) Then
            Return Me.getIn()
        End If
        If keyData = (Keys.Control Or Keys.R) Then
            Return Me.DmloaihangmucIUltraGrid.getRefresh()
        End If
        If keyData = (Keys.Control Or Keys.E) Then
            Return Me.DmloaihangmucIUltraGrid.getSua()
        End If
        If keyData = (Keys.Control Or Keys.Q) Then
            Return getThoat()
        End If
        If keyData = (Keys.Escape) Then
            Return getThoat()
        End If
        Return MyBase.ProcessCmdKey(msg, keyData)
    End Function

    Private Sub dmLoaiHangMuc_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Cursor = Cursors.WaitCursor
        Me.DmtinhtrangTableAdapter.Fill(Me.ErpharmaDataSet.dmtinhtrang)
        Me.DmloaihangmucTableAdapter.Fill(Me.ErpharmaDataSet.dmloaihangmuc)
        Me.DmloaihangmucIUltraGrid.setDoiTuongXuLyDuLieu(Me.ErpharmaDataSet.dmloaihangmuc, Me.DmloaihangmucBindingSource, Me.DmloaihangmucTableAdapter, Me.ErpharmaDataSet)
        Me.DmloaihangmucIUltraGrid.setGiaoDienVua()
        Me.DmloaihangmucIUltraGrid.setTimKiemTrenCotUltraGrid()
        Me.DmloaihangmucIUltraGrid.setChoPhepLuuXongKhongThemDong()
        Me.DmloaihangmucIUltraGrid.setChoPhepMenuStrip()
        Me.DmloaihangmucIUltraGrid.setThemIUltraDropDown(Me.DmtinhtrangIUltraDropDown, Me.ErpharmaDataSet.dmtinhtrang)
        Me.DmtinhtrangIUltraDropDown.setGiaoDien_An_ColumnHeader()
        Me.DmloaihangmucIUltraGrid.setReadonly(True)
        Me.Cursor = Cursors.Default

    End Sub
    Private Sub btnTaoMoi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTaoMoi.Click
        Me.DmloaihangmucIUltraGrid.getTaoMoi()
    End Sub
    Private Sub btnLuu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLuu.Click
        Me.DmloaihangmucIUltraGrid.getLuu()
    End Sub
    Private Sub btnXoa_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnXoa.Click
        Me.DmloaihangmucIUltraGrid.getXoa()
    End Sub
    Private Sub btnLamTuoi_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLamTuoi.Click
        Me.DmloaihangmucIUltraGrid.getRefresh()
    End Sub
    Private Function getIn() As Boolean
        Try
            Dim rp As dmLoaiHangMuc_report = New dmLoaiHangMuc_report
            rp.setDt(Me.DmloaihangmucIUltraGrid.getDatatableTuIUltraGrid("dmloaihangmuc"))
            rp.Show()
            'Me.DmloaihangmucIUltraGrid.DataSource = Me.ErpharmaDataSet.dmloaihangmuc
        Catch ex As Exception
            Return False
        End Try
        Return True
    End Function
    Private Sub btnIn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnIn.Click
        getIn()
    End Sub
    Private Function getThoat() As Boolean
        Try
            If Me.DmloaihangmucIUltraGrid.getClose Then
            End If
            Me.Dispose()
            Me.Close()
        Catch ex As Exception
            Return False
        End Try
        Return True
    End Function
    Private Sub btnThoat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThoat.Click
        getThoat()
    End Sub

    Private Sub btnSua_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSua.Click
        Me.DmloaihangmucIUltraGrid.getSua()
    End Sub
End Class